﻿
@{
    ViewData["Title"] = "MenuList";
}
@using ViewModel.admin
@model PagerModel

<div class="weadmin-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">管理员管理</a>
        <a>
            <cite>菜单管理</cite>
        </a>
    </span>
    <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i>
    </a>
</div>
<div class="weadmin-body">
    <div class="weadmin-block">
        <button class="layui-btn" onclick="WeAdminShow('添加用户','@Url.Action("MenuEdit")')"><i class="layui-icon"></i>添加</button>
    </div>
    @Html.Raw(Model.Data)
</div>


@section Scripts{
    <script type="text/javascript">

        //layui-form-checked
        layui.extend({
	        admin: '{/}../../static/js/admin'
        });

        layui.use(['admin'], function () {
           
        });

        /*用户-删除*/
        window.member_del = function (obj, id) {
            layer.confirm('确认要删除吗？', function (index) {
                //发异步删除数据

                $.post("@Url.Action("MenuDelete")", { ids: id}, function (data) {
                    if (data=="success") {
                        layer.msg('已删除', {
                            icon: 1
                        });
                        $(obj).parents("tr").remove();
                    } else {
                        layer.msg('删除失败，原因：'+data, {
                            icon: 2
                        });
                    }
                })
            });
        }


        /*用户-停用*/
        window.member_stop = function (obj, id) {
            layer.confirm('确认要' + $(obj).attr('title') + '吗？', function (index) {
                if ($(obj).attr('title') == '启用') {
                     $.post("@Url.Action("SetState")", { id: id, IsEnable: 1 }, function (data) {
                        //发异步把用户状态进行更改
                        $(obj).attr('title', '停用')
                        $(obj).find('i').html('&#x1007;');
                        $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                        layer.msg('已启用!', {
                            icon: 1,
                            time: 1000
                        });
                    })
                } else {
                    $.post("@Url.Action("SetState")", { id: id, IsEnable: 0 }, function (data) {
                        $(obj).attr('title', '启用')
                        $(obj).find('i').html('&#xe605;');

                        $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                        layer.msg('已停用!', {
                            icon: 5,
                            time: 1000
                        });
                    });
                }
            })
        }


    </script>
}